﻿using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using MySql.Data.MySqlClient;
using Bass.Tools;

public partial class user_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        //Response.Write("<script>alert('我日你妹！');</script>");

        string username = Request.QueryString["username"];
        string userpassword = Request.QueryString["userpassword"];
        string txtCheckCode = Request.QueryString["txtCheckCode"];

        //Response.Write("<script>alert('"+ username +"');</script>");
        //Response.End();

        if ((username == null) || (username == ""))
        {
            Response.Write("<script>alert('用户名为空-页面将跳转回主页！');location.href='index.aspx';</script>");
            Response.End();
            //Response.Redirect("index.aspx");
        }

        if ((userpassword == null) || (userpassword == ""))
        {
            Response.Write("<script>alert('用户密码为空-页面将跳转回主页！');location.href='index.aspx';</script>");
            Response.End();
        }

        if ((txtCheckCode == null) || (txtCheckCode == ""))
        {
            Response.Write("<script>alert('验证码为空-页面将跳转回主页！');location.href='index.aspx';</script>");
            Response.End();
        }

        if (Request.Cookies["CheckCode"] == null)
        {
            lblMessage.Text = "您的浏览器设置已被禁用 Cookies，您必须设置浏览器允许使用 Cookies 选项后才能使用本系统。";
            lblMessage.Visible = true;
            return;
        }

        if (String.Compare(Request.Cookies["CheckCode"].Value, txtCheckCode, true) != 0)
        {
            lblMessage.Text = "错误：验证码错误";
            lblMessage.Visible = true;
            return;
        }

        //OleDbConnection Conn = new OleDbConnection();
        //Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("miumiu.mdb");
        //Conn.Open();

        //string pwd = userpassword.Text;
        //string pwd_md5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "md5");
        //string logining = "select count(*) from user_info where username='" + username.Text + "' and userpassword='" + pwd_md5 + "'";
        //OleDbCommand dap = new OleDbCommand(logining, Conn);
        //int count = (int)dap.ExecuteScalar();
        //if (count > 0)
        //{
        //    Session["username"] = username.Text.ToString();
        //    Conn.Close();
        //    Response.Write("<script>alert('登录成功！欢迎你，'+'" + username.Text + "'+'！');location='index.aspx'</script>");
        //}
        //else
        //{
        //    Conn.Close();
        //    Response.Write("<script>alert('用户名或者密码输入有误，请重新输入！');location='index.aspx'</script>");
        //}

    }



    /*protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        OleDbConnection Conn = new OleDbConnection();
        Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("miumiu.mdb");
        Conn.Open();

        string username = this.TextBox1.Text.ToString();
        OleDbCommand cmd = new OleDbCommand("select count(*) from user_info where username='" + username + "'", Conn);
        int count = Convert.ToInt32(cmd.ExecuteScalar());
        if (count > 0)
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }
    }*/



}
